/**
 * 公司：金丹科技
 * 文件：User
 * 作者：kong
 * 时间：2019/4/16 13:56
 * 描述：
 */

package com.springboot.test.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.thymeleaf.util.StringUtils;

import javax.servlet.http.HttpSession;
import java.util.Map;


@Controller
public class User {

    @PostMapping("/user/login")
//    @RequestMapping(value="/login",method = RequestMethod.POST)
     public String login(@RequestParam("username") String username, @RequestParam("password") String password, Map<String,String> map
    , HttpSession session  ){

        if(!StringUtils.isEmpty(username) && "123".equals(password)){
            session.setAttribute("loginuser",username);
            return "redirect:/main.html";
        }else{
            map.put("msg","用户名密码错误");
            return "index";
        }

     }

}
